<?php
namespace app\admin\validate;

use think\Validate;
use think\Db;
class AddProValidate extends Validate
{
    protected $rule = [
        'create_uid' 				=> 'require',
        'age_limit' 				=> 'require|number|between:0,20',
        'tuition' 					=> 'require|number|between:0,9999999999',
        'school' 					=> 'require',
        'school_id' 				=> 'require',
        'major' 					=> 'require',
        'major_id' 					=> 'require',
        'name' 						=> 'require',
        // 'c_name'                    => 'require',
        // 'c_id'                      => 'require',
		'attr_info'					=> 'rone',
    ];

    protected $message = [
        'name.require'  			=> '产品名称不能为空',
        'create_uid.require' 		=> '登录过期,请重新登录',
        'age_limit.require' 		=> '学期年限不能为空',
        'age_limit.number' 			=> '学期年限必须为数字',
        'age_limit.between' 		=> '学期年限必须在0~20之间',
        'tuition.require' 			=> '学费不能为空',
        'tuition.number' 			=> '学费必须为必须为数字',
        'tuition.between' 			=> '学费必须大于0',
        // 'c_id.require'              => '请选择所属分类',
        // 'c_name.require'            => '请选择所属分类',
        'school_id.require'         => '请选择学校和专业',
        'school.require'            => '请选择学校和专业',
		'attr_info.rone'  			=> '产品属性不能为空',
    ];

    protected function rone($value){
        if($value == '[]'){
            return false;
        }else{
            return true;
        }
    }
}
